package com.tjp.eight.ui.fragment.mywallet.zfb;

import com.tjp.eight.AllRetrofit;
import com.tjp.eight.base.BasePresenterImpl;
import com.tjp.eight.constant.UrlConstant;
import com.tjp.eight.net.NetCallBack;
import com.tjp.eight.net.SubscribeCallBack;
import com.tjp.eight.ui.fragment.mywallet.wx.TSResultModel;
import com.tjp.eight.utils.AppUtils;

import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/3/28.
 */
public class ZFBPresenter extends BasePresenterImpl<ZFBView>{
    private ZFBService service = AllRetrofit.getRetrofit(UrlConstant.BaseUrl).create(ZFBService.class);
    public ZFBPresenter(ZFBView view){
        attachView(view);
    }

    public void toZFB(String pJson) {
        RequestBody rq = AppUtils.getRequestBody(pJson);
        addSubscription(service.toZFB(rq),new SubscribeCallBack<>(new NetCallBack<TSResultModel>() {
            @Override
            public void onSuccess(TSResultModel model) {
                view.tSuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {
                view.fail(msg);
            }

            @Override
            public void onCompleted() {

            }
        }));
    }

    public void loaddata(String lpJson) {
        RequestBody body = AppUtils.getRequestBody(lpJson);
        addSubscription(service.load(body), new SubscribeCallBack<>(new NetCallBack<TZFBRModel>() {
            @Override
            public void onSuccess(TZFBRModel model) {
                view.loadSuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {

            }

            @Override
            public void onCompleted() {

            }
        }));
    }
}
